package com.wthink.newMain.serviceVoice

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.wthink.hzgj.R
import com.wthink.hzgj.databinding.FragmentServiceVoiceBinding
import com.wthink.hzgj.util.adapter.OnItemClickListener
import com.wthink.hzgj.util.closeDefaultAnimator
import com.wthink.newMain.main.MainNewActivity
import com.wthink.newMain.serviceVoice.adapter.ServiceVoiceAdapter
import com.wthink.newMain.serviceVoice.viewmodel.ServiceVoiceViewmodel

class ServiceVoiceFragment : Fragment(){

    private val viewModel by viewModels<ServiceVoiceViewmodel>()

    private lateinit var binding: FragmentServiceVoiceBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(
            inflater,
            R.layout.fragment_service_voice,
            container,
            false
        )
        binding.viewModel = viewModel
        binding.lifecycleOwner = this
        return binding.root
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        viewModel.query()

        binding.serviceRecycle.layoutManager = LinearLayoutManager(context,
            LinearLayoutManager.VERTICAL,false)

        binding.serviceRecycle.adapter = ServiceVoiceAdapter().apply {
            mItemClickListener = object : OnItemClickListener {
                override fun onItemClick(obj: Any, position: Int) {

                }
            }
        }
        closeDefaultAnimator(binding.serviceRecycle)
    }

    override fun onResume() {
        super.onResume()
    }

}
